#!/usr/bin/env python
# encoding: utf-8
'''
@author: 王震
@license: 四川凡狼科技有限公司
@contact: 2668985108@qq.com
@file: resources.py
@time: 2022/1/13 9:56 下午
@desc:
'''

from main import db
import datetime


class Resources(db.Model):
    __tablename__ = 'RESOURCES'

    id = db.Column(db.String(32), primary_key=True, unique=True, nullable=False, comment='id')
    resourcesTypeId = db.Column(db.String(32), unique=False, nullable=False, comment='资源类型id')
    name = db.Column(db.String(32), unique=True, nullable=False, comment='资源名称')
    imgUrl = db.Column(db.String(256), unique=False, nullable=True, comment='资源logo')
    star = db.Column(db.Integer, unique=False, nullable=False, default=1, comment='等级0-5')
    describe = db.Column(db.String(128), unique=False, nullable=True, comment='描述')
    label = db.Column(db.String(128), unique=False, nullable=True, comment='资源标签')
    urllib = db.Column(db.String(256), unique=False, nullable=False, comment='资源链接')
    details = db.Column(db.Text, unique=False, nullable=True, comment='资源详情')
    collection = db.Column(db.Integer, unique=False, nullable=False, default=0, comment='收藏')
    fabulous = db.Column(db.Integer, unique=False, nullable=False, default=0, comment='点赞')
    share = db.Column(db.Integer, unique=False, nullable=False, default=0, comment='分享')
    shoe = db.Column(db.Integer, unique=False, nullable=False, default=1, comment='1 线上 2 线下')
    LabelId = db.Column(db.Text, unique=False, nullable=True, comment='标签id')
    resourcesLabelId = db.Column(db.String(32), unique=False, nullable=False, comment='所属资源')
    createTime = db.Column(db.DateTime, unique=False, nullable=True, default=datetime.datetime.now, comment='创建时间')
    updateTime = db.Column(db.DateTime, unique=False, nullable=True, default=datetime.datetime.now,
                           onupdate=datetime.datetime.now, comment='更新时间')


class ResourcesLabel(db.Model):
    __tablename__ = 'RESOURCES_LABEL'

    id = db.Column(db.String(32), primary_key=True, unique=True, nullable=False, comment='id')
    name = db.Column(db.String(32), unique=True, nullable=False, comment='资源名称')
    shoe = db.Column(db.Integer, unique=False, nullable=False, default=1, comment='1 线上 2 线下')
    createTime = db.Column(db.DateTime, unique=False, nullable=True, default=datetime.datetime.now, comment='创建时间')
    updateTime = db.Column(db.DateTime, unique=False, nullable=True, default=datetime.datetime.now,
                           onupdate=datetime.datetime.now, comment='更新时间')


class LabelList(db.Model):
    __tablename__ = 'LABEL'

    id = db.Column(db.String(32), primary_key=True, unique=True, nullable=False, comment='id')
    name = db.Column(db.String(8), unique=True, nullable=False, comment='标签名称')
    shoe = db.Column(db.Integer, unique=False, nullable=False, default=1, comment='1 线上 2 线下')
    createTime = db.Column(db.DateTime, unique=False, nullable=True, default=datetime.datetime.now, comment='创建时间')
    updateTime = db.Column(db.DateTime, unique=False, nullable=True, default=datetime.datetime.now,
                           onupdate=datetime.datetime.now, comment='更新时间')


class Appreciate(db.Model):
    __tablename__ = 'APPRECIATE'

    id = db.Column(db.String(32), primary_key=True, unique=True, nullable=False, comment='点赞')
    userId = db.Column(db.String(32), unique=False, nullable=False, comment='userId')
    # 出现了严重的错误
    resourcesId = db.Column(db.String(32), unique=True, nullable=False, comment='资源id¬')


class CollectionWorks(db.Model):
    __tablename__ = 'COLLECTION_WORKS'

    id = db.Column(db.String(32), primary_key=True, unique=True, nullable=False, comment='id')
    userId = db.Column(db.String(32), unique=False, nullable=False, comment='用户id')
    resourcesId = db.Column(db.String(32), unique=False, nullable=False, comment='资源id')
